/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.brainstretch.jsf;

import java.io.Serializable;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import org.brainstretch.ejb.managers.RecommendationManager;
import org.brainstretch.models.quizzes.Quiz;

/**
 *
 * @author mrodaitis
 */
@ManagedBean
@ViewScoped
public class RecommendationController implements Serializable{

    @EJB
    RecommendationManager recManager;
    
    @ManagedProperty("#{userController}")
    UserController userController;
    
    @ManagedProperty("#{quizController}")
    QuizController quizController;
            
    List<Quiz> recommended;
    private static final int NUM_QUIZZES = 3;


    public List<Quiz> getRecommended() {
        if(recommended == null){
            Quiz current = quizController.getQuiz();
            recommended = recManager.getSimilarQuizzes(current, NUM_QUIZZES);
        }
        return recommended;
    }

    
    public void turnDownRecommended(Quiz rejected){
        List<Quiz> newRecList = recManager.rejectRecommended(quizController.getQuiz(), rejected, null, NUM_QUIZZES);
        recommended = newRecList;
    }
    
    public void setRecommended(List<Quiz> recommended) {
        this.recommended = recommended;
    }

    public QuizController getQuizController() {
        return quizController;
    }

    public void setQuizController(QuizController quizController) {
        this.quizController = quizController;
    }

    public UserController getUserController() {
        return userController;
    }

    public void setUserController(UserController userController) {
        this.userController = userController;
    }
    
    
    
    
           
}
